@import org.silkframework.rule.LinkSpec
@import plugins.Context
@import controllers.rules.routes.Assets
@import org.silkframework.rule.evaluation.ReferenceLinks
@import controllers.core.routes.{Assets => CoreAssets}

@(population: org.silkframework.learning.individual.Population,
  referenceLinks: ReferenceLinks,
  context: Context[LinkSpec])

@defining(3) { threshold =>

  <script type="text/javascript" src="@CoreAssets.at("libs/jsplumb/jsPlumb-2.1.8-min.js")"></script>
  <script type="text/javascript" src="@Assets.at("js/editor/editor.js")"></script>

  @if(population.isEmpty) {
    <div class="alert alert-info"><strong>No linkage rule learned yet.</strong></div>
  } else {
    @if(referenceLinks.positive.size >= threshold) {
      @ruleGraph(population.bestIndividual.node.build, context)
      <script type="text/javascript">
        $("#hide_graph_button").prop('disabled', false);
      </script>
    } else {
      <div class="alert alert-info"><strong>You need to confirm at least @{threshold} resource pairs, before a candidate rule can be shown.</strong></div>
    }

    <script type="text/javascript">
      @if(!population.isEmpty) {
        $("#learning_fitness_info").html("Fitness: @{"%.1f".format((population.bestIndividual.fitness) * 100)} (based on @referenceLinks.positive.size positive and @referenceLinks.negative.size negative reference links)");
      }
    </script>

  }

}